<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" :inline="true">
      <el-form-item label="事项标题：" prop="itemName">
        <el-input
          v-model="queryParams.itemName"
          placeholder=""
          clearable
          size="small"
          style="width: 240px"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>

      <el-form-item label="模块名称：" prop="module">
        <el-input
          v-model="queryParams.module"
          placeholder=""
          clearable
          size="small"
          style="width: 240px"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>

      <el-form-item label="任务名称：" prop="taskName">
        <el-input
          v-model="queryParams.taskName"
          placeholder=""
          clearable
          size="small"
          style="width: 240px"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>

      <el-form-item label="待办人名称：" prop="todoUserName">
        <el-input
          v-model="queryParams.todoUserName"
          placeholder=""
          clearable
          size="small"
          style="width: 240px"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="处理人名称：" prop="handleUserName">
        <el-input
          v-model="queryParams.handleUserName"
          placeholder=""
          clearable
          size="small"
          style="width: 240px"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="通知时间：" prop="taskName">
        <el-input
          v-model="queryParams.taskName"
          placeholder=""
          clearable
          size="small"
          style="width: 240px"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="处理时间：" prop="taskName">
        <el-input
          v-model="queryParams.taskName"
          placeholder=""
          clearable
          size="small"
          style="width: 240px"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
     
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>

    <el-table v-loading="loading" :data="todoList" @selection-change="handleSelectionChange">
      <el-table-column type="selection" width="55"  align="center" />
      <el-table-column label="事项标题" prop="itemName" min-width="8%" />
      <el-table-column label="事项内容" prop="itemContent"  min-width="8%" />
      <el-table-column label="模块名称" prop="module"  min-width="8%" />
      <el-table-column label="任务 ID" prop="taskId"  min-width="10%" />
      <el-table-column label="任务名称" prop="taskName"  min-width="14%" />
      <el-table-column label="待办人名称" prop="todoUserName"  min-width="8%" />
      <el-table-column label="申请人名称" prop="handleUserName"  min-width="8%" />
      <el-table-column label="通知时间" prop="todoTime"  min-width="8%">
        <template slot-scope="scope">
          <span>{{ moment(scope.row.todoTime).format('YYYY-MM-DD HH:mm:ss') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="处理时间" prop="handleTime"  min-width="10%" />
      <el-table-column label="待办任务名称" min-width="10%" >
        <template slot-scope="scope">
          <span style="color:#F00; font-weight:bold">{{ scope.row.nodeName }}</span>
        </template>
      </el-table-column>
      <el-table-column label="操作" align="center" class-name="small-padding fixed-width" min-width="45%">
        <template slot-scope="scope">
          <el-button
            size="small"
            round
            type="primary"
            icon="el-icon-edit"
            @click="handleApproval(scope.row)"
          >办理</el-button>
          <el-button
            size="small"
            round
            type="info"
            icon="el-icon-news"
            @click="handleUpdate(scope.row)"
          >委托</el-button>
          <el-button
            size="small"
            type="warning"
            round
            icon="el-icon-circle-check"
            @click="handleDeploy(scope.row)"
          >申请详情</el-button>
          <el-button
            size="small"
            type="danger"
            round
            icon="el-icon-document"
            @click="handleExport(scope.row)"
          >审批历史</el-button>
          <el-button
            size="small"
            type="success"
            round
            icon="el-icon-user"
            @click="handleDelete(scope.row)"
          >进度查看</el-button>
        </template>
      </el-table-column>
      
   </el-table>

    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />
  <el-dialog :visible.sync="dialogParams.tdlvOpen" :title="dialogParams.tdlvTitle" width="600px" append-to-body >
      <el-form ref="form" :model="taskDeptLeaderVerify" label-width="90px">
        <el-form-item label="申请人：" >
          <el-input v-model="taskDeptLeaderVerify.handleUserName" placeholder="" :readonly="true" />
        </el-form-item>
        <el-form-item label="结束时间: ">
          <el-date-picker clearable size="small" style="width: 200px" :readonly="true"
            v-model="taskDeptLeaderVerify.endTime"
            type="date"
            value-format="yyyy-MM-dd"
            placeholder="">
          </el-date-picker>
        </el-form-item>
        <el-form-item label="标题：">
          <el-input v-model="taskDeptLeaderVerify.itemName"  placeholder="" :readonly="true"/>
        </el-form-item>
        <el-form-item label="原因：">
          <el-input v-model="taskDeptLeaderVerify.itemContent"  placeholder="" :readonly="true"/>
        </el-form-item>
        <el-form-item label="开始时间: ">
          <el-date-picker clearable size="small" style="width: 200px" :readonly="true"
            v-model="taskDeptLeaderVerify.startTime"
            type="date"
            value-format="yyyy-MM-dd"
            placeholder="选择开始时间">
          </el-date-picker>
        </el-form-item>
        <el-form-item label="结束时间: ">
          <el-date-picker clearable size="small" style="width: 200px" :readonly="true"
            v-model="taskDeptLeaderVerify.endTime"
            type="date"
            value-format="yyyy-MM-dd"
            placeholder="选择结束时间">
          </el-date-picker>
        </el-form-item>
        <el-form-item label="请假时长: ">
          <el-input v-model="taskDeptLeaderVerify.totalTime" placeholder="" :readonly="true" />
        </el-form-item>
     
        <el-form-item label="审批意见：" >
           <div class="type-select">
              <select v-model="p_B_deptLeaderApproved">
                <option value="true" default>同意</option> 
                <option value="false" >拒绝</option> 
              </select>
            </div>
        </el-form-item>
        <el-form-item label="批注：">
           <el-input type="textarea" v-model="comment" placeholder="" clearable size="small"/>
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitFileForm(taskDeptLeaderVerify.taskId)">确 定</el-button>
        <el-button @click="dialogParams.tdlvOpen = false">取 消</el-button>
      </div>
    </el-dialog>
 </div>
</template>

<script>

import { listMyTodo } from "@/api/process/todoList/myTodo";

export default {
  name: "MyTodo",
  data() {
    return {
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 总条数
      total: 0,
      // 角色表格数据
      todoList: [],
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        itemName: undefined,
        module: undefined,
        taskName: undefined,
        todoUserName: undefined,
        handleUserName: undefined
      },
      // 部门领导审核参数
      taskDeptLeaderVerify: {},
      p_B_deptLeaderApproved: undefined,
      comment: undefined,
       // 弹窗参数
      dialogParams: {
        tdlvOpen: false,
        tdlvTitle: ""
      },
      // 表单参数
      form: {},
      defaultProps: {
        children: "children",
        label: "label"
      }
    };

  },
  created() {
    this.getList();
    
  },
  methods: {
    /** 查询角色列表 */
    getList() {
      this.loading = true;
      listMyTodo(this.queryParams).then(
        response => {
          this.todoList = response.rows;
          this.total = response.total;
          this.loading = false;
        }
      );
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map(item => item.id)
      this.single = selection.length!=1
      this.multiple = !selection.length
    },

    /** 审批按钮操作 */
    handleApproval(row) {
      this.taskDeptLeaderVerify=row;
      this.dialogParams.tdlvOpen =true;
      this.dialogParams.tdlvTitle = "部门领导审批"
    },

  }
};
</script>